CREATE TABLE [dbo].[Note]
(
[NoteKey] [uniqueidentifier] NOT NULL,
[NoteText] [ntext] COLLATE SQL_Latin1_General_CP1_CI_AS NOT NULL,
[NotePurposeKey] [uniqueidentifier] NOT NULL,
[CreatedOn] [datetime] NOT NULL CONSTRAINT [DF_Note_CreatedOn] DEFAULT (getdate()),
[CreatedByUserKey] [uniqueidentifier] NOT NULL,
[UpdatedOn] [datetime] NOT NULL CONSTRAINT [DF_Note_UpdatedOn] DEFAULT (getdate()),
[UpdatedByUserKey] [uniqueidentifier] NOT NULL,
[NoteForUniformKey] [uniqueidentifier] NOT NULL,
[AccessKey] [uniqueidentifier] NOT NULL,
[MarkedForDeleteOn] [datetime] NULL
) ON [PRIMARY] TEXTIMAGE_ON [PRIMARY]
GO
ALTER TABLE [dbo].[Note] ADD CONSTRAINT [PK_Note] PRIMARY KEY CLUSTERED ([NoteKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Note_AccessKey] ON [dbo].[Note] ([AccessKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Note_CreatedByUserKey] ON [dbo].[Note] ([CreatedByUserKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Note_NoteForUniformKey] ON [dbo].[Note] ([NoteForUniformKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Note_NotePurposeKey] ON [dbo].[Note] ([NotePurposeKey]) ON [PRIMARY]
GO
CREATE NONCLUSTERED INDEX [IX_Note_UpdatedByUserKey] ON [dbo].[Note] ([UpdatedByUserKey]) ON [PRIMARY]
GO
ALTER TABLE [dbo].[Note] ADD CONSTRAINT [FK_Note_AccessMain] FOREIGN KEY ([AccessKey]) REFERENCES [dbo].[AccessMain] ([AccessKey])
GO
ALTER TABLE [dbo].[Note] ADD CONSTRAINT [FK_Note_NotePurposeRef] FOREIGN KEY ([NotePurposeKey]) REFERENCES [dbo].[NotePurposeRef] ([NotePurposeKey])
GO
ALTER TABLE [dbo].[Note] ADD CONSTRAINT [FK_Note_UniformRegistry] FOREIGN KEY ([NoteKey]) REFERENCES [dbo].[UniformRegistry] ([UniformKey])
GO
ALTER TABLE [dbo].[Note] ADD CONSTRAINT [FK_Note_UniformRegistry_NoteFor] FOREIGN KEY ([NoteForUniformKey]) REFERENCES [dbo].[UniformRegistry] ([UniformKey])
GO
ALTER TABLE [dbo].[Note] ADD CONSTRAINT [FK_Note_UserMain_CreatedBy] FOREIGN KEY ([CreatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO
ALTER TABLE [dbo].[Note] ADD CONSTRAINT [FK_Note_UserMain_UpdatedBy] FOREIGN KEY ([UpdatedByUserKey]) REFERENCES [dbo].[UserMain] ([UserKey])
GO